<?php

namespace App\Http\Controllers\Configuration;

use Doctrine\Common\Cache\PredisCache;
use EasyWeChat\Foundation\Application as WechatApplication;

use Illuminate\Container\Container;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;

class WechatController
{
    public function makeJsSDKConfigs(Request $request)
    {
        $application = Container::getInstance()->make('wechat.plateform');
        $url = $request->url;
        $application->config->app_id= 'wx2a564a67a378ae52';
        $application->config->secret= '3ce553f3c0a7db20bc06de9eef279152';
        $js = $application->js;
        if ($url) {
            $js->setUrl($url);
        }
        try {
            $config = $js->config([
                'onMenuShareTimeline',
                'onMenuShareAppMessage',
                'onMenuShareQQ',
                'onMenuShareWeibo',
                'onMenuShareQZone',
            ], config('app.debug'), false, false);

            return response()->success($config);
        } catch (\Exception $exception) {
            return response()->failed($exception->getMessage());
        }
    }
}
